﻿@if (DocStatus != Utils.DocStatus.View)
{
    <div>
        <div style="float: right;">
            <PopConfirmButton Color="Color.Danger" IsDisabled="@IsDeleteDisabled" OnConfirm="(() => DeleteLicense(LicenseModel))" ConfirmIcon="fa-solid fa-triangle-exclamation text-danger" ConfirmButtonColor="Color.Danger" Content="@deleteMessage">删除证照</PopConfirmButton>
        </div>
    </div>
    <div>
        <CardUpload Accept="application/pdf;image/*" DefaultFileList="@LicenseFile" IsSingle="true" TValue="string" ShowProgress="true" ShowDeletedButton="true" ShowZoomButton="false" ShowDownloadButton="true" OnChange="@OnLicenseFileChange" OnDownload="OnDownload">上传证照</CardUpload>
        <Button Color="Color.Primary" OnClick="ShowPreviewer" IsDisabled="@(!LicenseFile.Any())" Icon="fa-solid fa-magnifying-glass" Text="预览" />
        <ImagePreviewer @ref="ImagePreviewer" PreviewList="PreviewList"></ImagePreviewer>
    </div>
    @*<CardUpload Accept="image/*" DefaultFileList="@LicenseFile" IsSingle="true" TValue="string" ShowProgress="true" ShowDeleteButton="true" ShowDownloadButton="true" OnChange="@OnLicenseFileChange" OnDownload="OnDownload">上传证照</CardUpload>*@
    <ValidateForm Model="@LicenseModel" ValidateAllProperties="true" style="margin-top: 1rem;" OnInvalidSubmit="OnInvalidSubmit" OnValidSubmit="OnValidSubmit">
        <GroupBox style="margin-top: 1rem;">
            <EditorForm TModel="ManufacturerLicense" Model="LicenseModel" AutoGenerateAllItem="false" ItemsPerRow="4">
                <FieldItems>
                    <div class="col-12 col-sm-4" style="margin-bottom: 1rem;">
                        <Select @bind-Value="@context.Type" Items="@ManufacturerLicenseTypeList" />
                    </div>
                    <EditorItem @bind-Field="@context.Name" Readonly="@IsFieldReadOnly" />
                    <EditorItem @bind-Field="@context.LId" Readonly="@IsFieldReadOnly" />
                    <EditorItem @bind-Field="@context.ValidFromDate" Readonly="@IsFieldReadOnly" />
                    <EditorItem @bind-Field="@context.ValidToDate" Readonly="@IsFieldReadOnly" />
                    <EditorItem @bind-Field="@context.CreatedOn" Readonly="true" />
                    <EditorItem @bind-Field="@context.CreatedBy" Readonly="true" />
                    <EditorItem @bind-Field="@context.LastModifiedOn" Readonly="true" />
                    <EditorItem @bind-Field="@context.LastModifiedBy" Readonly="true" />
                </FieldItems>
            </EditorForm>
            <div class="col-12 col-sm-6" style="margin-top: 1rem;">
                <span>档案资料</span>
                <ButtonUpload TValue="string" IsMultiple="true" ShowDownloadButton="true" DefaultFileList="@OtherFile" OnChange="@OnOtherFileChange" OnDownload="@OnDownload"></ButtonUpload>
            </div>
        </GroupBox>
        @*<div class="col-12 col-sm-6">
                <span>上传证照</span>
                <CardUpload Accept="image/*" DefaultFileList="@Base64FormatFile" IsSingle="true" TValue="string" ShowProgress="true" ShowDeleteButton="true" ShowDownloadButton="true">上传证照</CardUpload>
                <span>其他附件</span>
                <ButtonUpload TValue="string" IsMultiple="true" ShowDownloadButton="true" DefaultFileList="@OtherFileList"></ButtonUpload>
            </div>*@
        <div class="form-footer mt-3">
            <button type="button" class="btn btn-secondary" @onclick="@(e => OnClose?.Invoke())">
                <i class="fa-solid fa-xmark"></i>
                <span>关闭</span>
            </button>
            <Button Color="Color.Primary" ButtonType="ButtonType.Submit" IsDisabled="@IsButtonDisabled" Icon="fa-solid fa-floppy-disk" Text="确认" />
        </div>
    </ValidateForm>
}
else
{
    <div>
        <CardUpload Accept="application/pdf;image/*" DefaultFileList="@LicenseFile" IsSingle="true" TValue="string" ShowProgress="true" ShowDeletedButton="false" ShowZoomButton="false" ShowDownloadButton="true" OnChange="@OnLicenseFileChange" OnDownload="OnDownload">上传证照</CardUpload>
        <Button Color="Color.Primary" OnClick="ShowPreviewer" IsDisabled="@(!LicenseFile.Any())" Icon="fa-solid fa-magnifying-glass" Text="预览" />
        <ImagePreviewer @ref="ImagePreviewer" PreviewList="PreviewList"></ImagePreviewer>
    </div>
    <ValidateForm Model="@LicenseModel" ValidateAllProperties="true" style="margin-top: 1rem;" OnInvalidSubmit="OnInvalidSubmit" OnValidSubmit="OnValidSubmit">
        <GroupBox style="margin-top: 1rem;">
            <EditorForm TModel="ManufacturerLicense" Model="LicenseModel" AutoGenerateAllItem="false" ItemsPerRow="4">
                <FieldItems>
                    <div class="col-12 col-sm-4" style="margin-bottom: 1rem;">
                        <Select @bind-Value="@context.Type" Items="@ManufacturerLicenseTypeList" />
                    </div>
                    <EditorItem @bind-Field="@context.Name" Readonly="@IsFieldReadOnly" />
                    <EditorItem @bind-Field="@context.LId" Readonly="@IsFieldReadOnly" />
                    <EditorItem @bind-Field="@context.ValidFromDate" Readonly="@IsFieldReadOnly" />
                    <EditorItem @bind-Field="@context.ValidToDate" Readonly="@IsFieldReadOnly" />
                    <EditorItem @bind-Field="@context.CreatedOn" Readonly="true" />
                    <EditorItem @bind-Field="@context.CreatedBy" Readonly="true" />
                    <EditorItem @bind-Field="@context.LastModifiedOn" Readonly="true" />
                    <EditorItem @bind-Field="@context.LastModifiedBy" Readonly="true" />
                </FieldItems>
            </EditorForm>
            <div class="col-12 col-sm-6" style="margin-top: 1rem;">
                <span>档案资料</span>
                <ButtonUpload TValue="string" IsMultiple="true" ShowDownloadButton="true" DefaultFileList="@OtherFile" OnChange="@OnOtherFileChange" OnDownload="@OnDownload"></ButtonUpload>
            </div>
        </GroupBox>
        @*<div class="col-12 col-sm-6">
                <span>上传证照</span>
                <CardUpload Accept="image/*" DefaultFileList="@Base64FormatFile" IsSingle="true" TValue="string" ShowProgress="true" ShowDeleteButton="true" ShowDownloadButton="true">上传证照</CardUpload>
                <span>其他附件</span>
                <ButtonUpload TValue="string" IsMultiple="true" ShowDownloadButton="true" DefaultFileList="@OtherFileList"></ButtonUpload>
            </div>*@
        <div class="form-footer mt-3">
            <button type="button" class="btn btn-secondary" @onclick="@(e => OnClose?.Invoke())">
                <i class="fa-solid fa-xmark"></i>
                <span>关闭</span>
            </button>
        </div>
    </ValidateForm>
}